package nio.nio.zeroCopy;

import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.Socket;

/**
 * @author 帅小伙
 * @date 2022/1/15
 * @description
 */
public class OldIOClient {

    public static void main(String[] args) throws Exception {
        Socket socket = new Socket("127.0.0.1", 7000);

        String fileName = "file1.txt";
        FileInputStream inputStream = new FileInputStream(fileName);

        DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());

        byte[] bytes = new byte[1024];

        long readCount ;
        long total = 0;

        while((readCount = inputStream.read(bytes)) >= 0) {
            total += readCount;
            dataOutputStream.write(bytes);
        }

        System.out.println("发送总字节数"+total);

        dataOutputStream.close();
        socket.close();
        inputStream.close();
    }
}
